﻿using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using Zhaoxi.NET7.DemoProject.Models;

namespace Zhaoxi.NET7.DemoProject.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;
        private readonly IConfiguration _iConfiguration;
        private static long _Version = 1;
        public HomeController(ILogger<HomeController> logger, IConfiguration configuration)
        {
            _logger = logger;
            this._iConfiguration = configuration;
        }

        public IActionResult Index()
        {
            Console.WriteLine($"This is HomeController Index {_Version++}");
            base.ViewBag.Urls = this._iConfiguration["urls"];
            base.ViewBag.Para = this._iConfiguration["ip"] + " : " + this._iConfiguration["port"];
            base.ViewBag.Version = _Version;

            return View();
        }

        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}